/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.sbbs.contoeth;

import java.util.concurrent.ExecutionException;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.methods.response.Web3ClientVersion;

/**
 *
 * @author qskj
 */
public class EthTools {

    //获得Web3j对象，URL为geth私链的地址
//你需要换成你的地址，如果是本地的话是局域网IP+设置的端口号，默认是8545
    /**
     * 获取版本等信息
     *
     * @param web3j
     */
    public static String getInfo(Web3j web3j) {
        Web3ClientVersion web3ClientVersion = null;
        String clientVersion = null;
        try {
            web3ClientVersion = web3j.web3ClientVersion().sendAsync().get();
            clientVersion = web3ClientVersion.getWeb3ClientVersion();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
        return clientVersion;
    }

}
